<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

spl_autoload_register(array(new HTML_Fluent_Autoloader(), 'autoload'));

class HTML_Fluent_Autoloader {
    protected $root;

    public function __construct() {
        $this->root = dirname(__FILE__);
        for ($i=0; $i<2; $i++) {
            $this->root .= DIRECTORY_SEPARATOR .'..';
        }
    }

    public function autoload($name) {
        if (!strpos($name, 'HTML_Fluent') === 0) {
            return false;
        }
        $path = $this->root . DIRECTORY_SEPARATOR;
        $path .= str_replace('_', DIRECTORY_SEPARATOR, $name);
	$path .= '.php';
        if (file_exists($path) && is_readable($path)) {
            require_once $path;
            return true;
        }
        return false;
    }
}

